O(1): Constant time operations (e.g., accessing an element by index).
O(n): Linear time operations (e.g., traversing the array).
O(log n): Logarithmic time (e.g., binary search on a sorted array).
O(n^2): Quadratic time (e.g., nested loops for pairwise comparison).
O(n log n): Linearithmic time (e.g., efficient sorting algorithms like mergesort).
O(2^n): Exponential time (e.g., generating all subsets).
Best, Worst, and Average Case:
Best Case: The scenario where the algorithm performs the minimum number of steps (e.g., searching for the first element in a linear search).
Worst Case: The scenario where the algorithm performs the maximum number of steps (e.g., searching for a non-existent element in a linear search).
Average Case: The expected number of steps the algorithm takes, averaged over all possible inputs (e.g., searching for a random element in a linear search).
Array Problems:
Generate all possible combinations of a phone numberHTML